﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.Common;
using Automobile.service.UI;
using Automobile.service.Model;
using Automobile.service.BLL;
using System.Data;
namespace Automobile.service.UI
{
    public partial class mem_alter : System.Web.UI.Page
    {
        MemberCardBLL bll = new MemberCardBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int id = int.Parse(Request.QueryString["mid"]);
                DataTable table = bll.GetMemberCardByID(id);
                HiddenField1.Value = id.ToString();
                this.MemberCard_Name.Value = table.Rows[0]["MemberCard_Name"].ToString();
                this.MemberCard_owner.Value = table.Rows[0]["MemberCard_owner"].ToString();
                this.MemberCard_Cnum.Value = table.Rows[0]["MemberCard_Cnum"].ToString();
                this.MemberCard_CardID.Value = table.Rows[0]["MemberCard_CardID"].ToString();
                this.MemberCard_ingeral.Value = table.Rows[0]["MemberCard_ingeral"].ToString();
                this.MemberCard_sphere.Value = table.Rows[0]["MemberCard_sphere"].ToString();
                this.MemberCardRank_Rank.Value = table.Rows[0]["MemberCardRank_Rank"].ToString();

            }
        }

        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            MemberCard m = new MemberCard();
            m.MemberCard_Id = Convert.ToInt32(HiddenField1.Value);
            m.MemberCard_Name = this.MemberCard_Name.Value;
            m.MemberCard_owner = this.MemberCard_owner.Value;
            m.MemberCard_Cnum = this.MemberCard_Cnum.Value;
            m.MemberCard_CardID = this.MemberCard_CardID.Value;
            m.MemberCard_ingeral = Convert.ToInt32(this.MemberCard_ingeral.Value);
            m.MemberCard_sphere = Convert.ToDecimal(this.MemberCard_sphere.Value);
            m.MemberCardRank_Rank = this.MemberCardRank_Rank.Value;
            if (bll.UptMemberCardByID(m) > 0)
            {
                JournalBLL jbll = new JournalBLL();
                jbll.AddJourna_UptMemberCardByID(Convert.ToInt32(Session["empid"]),m);
                Response.Write("<script>alert('修改成功');parent.location.reload();parent.layer.close(parent.layer.getFrameIndex(window.name));</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败');parent.layer.close(parent.layer.getFrameIndex(window.name));</script>");
            }
        }
        
    }
}